import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:s_utils/s_utils.dart';

class IAppLink {
  static late Function(Map) redirectAction;
  static late Function(Uri? uri) handleUrl;
  static late AppLinks appLinks;
  static StreamSubscription<Uri>? linkSubscription;

  static Future<void> initDeepLinks() async {
    appLinks = AppLinks();
    // Handle links
    linkSubscription = appLinks.uriLinkStream.listen((uri) {
      logger.w('onAppLink: $uri');
      handleUrl(uri);
    }, onError: (Object err) {
      logger.e('AppLink err: $err');
    });
  }

}
